package net.sdd.school.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sdd.common.result.Result;
import net.sdd.school.entity.vo.SubjectTreeVo;
import net.sdd.school.service.ISubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author Jet
 * @since 2022-08-19
 */
@RestController
@RequestMapping("/sddonline/subject")
@Api(tags = "课程分类")
public class SubjectController {

    @Autowired
    private ISubjectService subjectService;

    @PostMapping("/import")
    @ApiOperation("导入课程分类")
    public Result importExcel(@RequestPart MultipartFile file) {
        subjectService.importExcel(file);
        return Result.ok();
    }

    @GetMapping("/findAllSubject")
    @ApiOperation("查询所有分类（一级、二级）")
    public Result findSubjects() {
        List<SubjectTreeVo> list = subjectService.findAllSubject();
        return Result.ok().data("list",list);
    }
}

